package com.xunshibao.web.tag;

import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspTagException;
import javax.servlet.jsp.tagext.DynamicAttributes;
import javax.servlet.jsp.tagext.TagSupport;

import com.xunshibao.util.DateUtil;

public class IntDateTag extends TagSupport implements DynamicAttributes  {
	/**
	 * 
	 */
	private static final long serialVersionUID = -2254446245289577713L;
	private Integer value;
	private static final SimpleDateFormat formater = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");

	public void setValue(Integer value) {
		this.value = value;
	}

	@Override
	public int doEndTag() throws JspException {
		if(value != null) {
			Date dt = DateUtil.int2Date(value);
			String v = formater.format(dt);
			try {
				pageContext.getOut().write(v);
			} catch (IOException e) {
				throw new JspTagException(e);
			}
		}
		return super.doEndTag();
	}

	@Override
	public void setDynamicAttribute(String arg0, String arg1, Object arg2) throws JspException {
		// TODO Auto-generated method stub
		
	}
}
